/**
 * This is a generated class and is not intended for modification.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - VoSCHeaderSearch.as.
 */

package com.model.valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.util.FiberUtils;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.binding.utils.ChangeWatcher;
import mx.events.PropertyChangeEvent;
import mx.validators.ValidationResult;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_VoSCHeaderSearch extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void
    {
        try
        {
            if (flash.net.getClassByAlias("VoSCHeaderSearch") == null)
            {
                flash.net.registerClassAlias("VoSCHeaderSearch", cz);
            }
        }
        catch (e:Error)
        {
            flash.net.registerClassAlias("VoSCHeaderSearch", cz);
        }
    }

    model_internal static function initRemoteClassAliasAllRelated() : void
    {
    }

    model_internal var _dminternal_model : _VoSCHeaderSearchEntityMetadata;

    /**
     * properties
     */
    private var _internal_currency_serialnumber_fk : int;
    private var _internal_customer_serialnumber_fk : Number;
    private var _internal_sc_gst : Number;
    private var _internal_sales_con_status : String;
    private var _internal_currency_name : String;
    private var _internal_no_of_days : String;
    private var _internal_sales_con_date : String;
    private var _internal_sc_serialnumber : int;
    private var _internal_current_rate : Number;
    private var _internal_sales_con_code : String;
    private var _internal_customer : String;
    private var _internal_sc_remarks : String;

    private static var emptyArray:Array = new Array();

    // Change this value according to your application's floating-point precision
    private static var epsilon:Number = 0.0001;

    /**
     * derived property cache initialization
     */
    model_internal var _cacheInitialized_isValid:Boolean = false;

    model_internal var _changeWatcherArray:Array = new Array();

    public function _Super_VoSCHeaderSearch()
    {
        _model = new _VoSCHeaderSearchEntityMetadata(this);

        // Bind to own data properties for cache invalidation triggering
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "sales_con_status", model_internal::setterListenerSales_con_status));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "currency_name", model_internal::setterListenerCurrency_name));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "no_of_days", model_internal::setterListenerNo_of_days));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "sales_con_date", model_internal::setterListenerSales_con_date));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "sales_con_code", model_internal::setterListenerSales_con_code));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "customer", model_internal::setterListenerCustomer));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "sc_remarks", model_internal::setterListenerSc_remarks));

    }

    /**
     * data property getters
     */

    [Bindable(event="propertyChange")]
    public function get currency_serialnumber_fk() : int
    {
        return _internal_currency_serialnumber_fk;
    }

    [Bindable(event="propertyChange")]
    public function get customer_serialnumber_fk() : Number
    {
        return _internal_customer_serialnumber_fk;
    }

    [Bindable(event="propertyChange")]
    public function get sc_gst() : Number
    {
        return _internal_sc_gst;
    }

    [Bindable(event="propertyChange")]
    public function get sales_con_status() : String
    {
        return _internal_sales_con_status;
    }

    [Bindable(event="propertyChange")]
    public function get currency_name() : String
    {
        return _internal_currency_name;
    }

    [Bindable(event="propertyChange")]
    public function get no_of_days() : String
    {
        return _internal_no_of_days;
    }

    [Bindable(event="propertyChange")]
    public function get sales_con_date() : String
    {
        return _internal_sales_con_date;
    }

    [Bindable(event="propertyChange")]
    public function get sc_serialnumber() : int
    {
        return _internal_sc_serialnumber;
    }

    [Bindable(event="propertyChange")]
    public function get current_rate() : Number
    {
        return _internal_current_rate;
    }

    [Bindable(event="propertyChange")]
    public function get sales_con_code() : String
    {
        return _internal_sales_con_code;
    }

    [Bindable(event="propertyChange")]
    public function get customer() : String
    {
        return _internal_customer;
    }

    [Bindable(event="propertyChange")]
    public function get sc_remarks() : String
    {
        return _internal_sc_remarks;
    }

    /**
     * data property setters
     */

    public function set currency_serialnumber_fk(value:int) : void
    {
        var oldValue:int = _internal_currency_serialnumber_fk;
        if (oldValue !== value)
        {
            _internal_currency_serialnumber_fk = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "currency_serialnumber_fk", oldValue, _internal_currency_serialnumber_fk));
        }
    }

    public function set customer_serialnumber_fk(value:Number) : void
    {
        var oldValue:Number = _internal_customer_serialnumber_fk;
        if (isNaN(_internal_customer_serialnumber_fk) == true || Math.abs(oldValue - value) > epsilon)
        {
            _internal_customer_serialnumber_fk = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "customer_serialnumber_fk", oldValue, _internal_customer_serialnumber_fk));
        }
    }

    public function set sc_gst(value:Number) : void
    {
        var oldValue:Number = _internal_sc_gst;
        if (isNaN(_internal_sc_gst) == true || Math.abs(oldValue - value) > epsilon)
        {
            _internal_sc_gst = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sc_gst", oldValue, _internal_sc_gst));
        }
    }

    public function set sales_con_status(value:String) : void
    {
        var oldValue:String = _internal_sales_con_status;
        if (oldValue !== value)
        {
            _internal_sales_con_status = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sales_con_status", oldValue, _internal_sales_con_status));
        }
    }

    public function set currency_name(value:String) : void
    {
        var oldValue:String = _internal_currency_name;
        if (oldValue !== value)
        {
            _internal_currency_name = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "currency_name", oldValue, _internal_currency_name));
        }
    }

    public function set no_of_days(value:String) : void
    {
        var oldValue:String = _internal_no_of_days;
        if (oldValue !== value)
        {
            _internal_no_of_days = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "no_of_days", oldValue, _internal_no_of_days));
        }
    }

    public function set sales_con_date(value:String) : void
    {
        var oldValue:String = _internal_sales_con_date;
        if (oldValue !== value)
        {
            _internal_sales_con_date = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sales_con_date", oldValue, _internal_sales_con_date));
        }
    }

    public function set sc_serialnumber(value:int) : void
    {
        var oldValue:int = _internal_sc_serialnumber;
        if (oldValue !== value)
        {
            _internal_sc_serialnumber = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sc_serialnumber", oldValue, _internal_sc_serialnumber));
        }
    }

    public function set current_rate(value:Number) : void
    {
        var oldValue:Number = _internal_current_rate;
        if (isNaN(_internal_current_rate) == true || Math.abs(oldValue - value) > epsilon)
        {
            _internal_current_rate = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "current_rate", oldValue, _internal_current_rate));
        }
    }

    public function set sales_con_code(value:String) : void
    {
        var oldValue:String = _internal_sales_con_code;
        if (oldValue !== value)
        {
            _internal_sales_con_code = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sales_con_code", oldValue, _internal_sales_con_code));
        }
    }

    public function set customer(value:String) : void
    {
        var oldValue:String = _internal_customer;
        if (oldValue !== value)
        {
            _internal_customer = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "customer", oldValue, _internal_customer));
        }
    }

    public function set sc_remarks(value:String) : void
    {
        var oldValue:String = _internal_sc_remarks;
        if (oldValue !== value)
        {
            _internal_sc_remarks = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sc_remarks", oldValue, _internal_sc_remarks));
        }
    }

    /**
     * Data property setter listeners
     *
     * Each data property whose value affects other properties or the validity of the entity
     * needs to invalidate all previously calculated artifacts. These include:
     *  - any derived properties or constraints that reference the given data property.
     *  - any availability guards (variant expressions) that reference the given data property.
     *  - any style validations, message tokens or guards that reference the given data property.
     *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
     *  - the validity of the property (and the containing entity) if the given data property is required.
     */

    model_internal function setterListenerSales_con_status(value:flash.events.Event):void
    {
        _model.invalidateDependentOnSales_con_status();
    }

    model_internal function setterListenerCurrency_name(value:flash.events.Event):void
    {
        _model.invalidateDependentOnCurrency_name();
    }

    model_internal function setterListenerNo_of_days(value:flash.events.Event):void
    {
        _model.invalidateDependentOnNo_of_days();
    }

    model_internal function setterListenerSales_con_date(value:flash.events.Event):void
    {
        _model.invalidateDependentOnSales_con_date();
    }

    model_internal function setterListenerSales_con_code(value:flash.events.Event):void
    {
        _model.invalidateDependentOnSales_con_code();
    }

    model_internal function setterListenerCustomer(value:flash.events.Event):void
    {
        _model.invalidateDependentOnCustomer();
    }

    model_internal function setterListenerSc_remarks(value:flash.events.Event):void
    {
        _model.invalidateDependentOnSc_remarks();
    }


    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();
        var validationFailureMessages:Array = new Array();

        var propertyValidity:Boolean = true;
        if (!_model.sales_con_statusIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_sales_con_statusValidationFailureMessages);
        }
        if (!_model.currency_nameIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_currency_nameValidationFailureMessages);
        }
        if (!_model.no_of_daysIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_no_of_daysValidationFailureMessages);
        }
        if (!_model.sales_con_dateIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_sales_con_dateValidationFailureMessages);
        }
        if (!_model.sales_con_codeIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_sales_con_codeValidationFailureMessages);
        }
        if (!_model.customerIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_customerValidationFailureMessages);
        }
        if (!_model.sc_remarksIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_sc_remarksValidationFailureMessages);
        }

        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && propertyValidity;
    }

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
        var oldValue:Boolean = model_internal::_isValid;
        if (oldValue !== value)
        {
            model_internal::_isValid = value;
            _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }
    }

    /**
     * derived property getters
     */

    [Transient]
    [Bindable(event="propertyChange")]
    public function get _model() : _VoSCHeaderSearchEntityMetadata
    {
        return model_internal::_dminternal_model;
    }

    public function set _model(value : _VoSCHeaderSearchEntityMetadata) : void
    {
        var oldValue : _VoSCHeaderSearchEntityMetadata = model_internal::_dminternal_model;
        if (oldValue !== value)
        {
            model_internal::_dminternal_model = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }
    }

    /**
     * methods
     */


    /**
     *  services
     */
    private var _managingService:com.adobe.fiber.services.IFiberManagingService;

    public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
    {
        _managingService = managingService;
    }

    model_internal function set invalidConstraints_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_invalidConstraints;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;
            _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
        }
    }

    model_internal function set validationFailureMessages_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_validationFailureMessages;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;
            _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
        }
    }

    model_internal var _doValidationCacheOfSales_con_status : Array = null;
    model_internal var _doValidationLastValOfSales_con_status : String;

    model_internal function _doValidationForSales_con_status(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfSales_con_status != null && model_internal::_doValidationLastValOfSales_con_status == value)
           return model_internal::_doValidationCacheOfSales_con_status ;

        _model.model_internal::_sales_con_statusIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isSales_con_statusAvailable && _internal_sales_con_status == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "sales_con_status is required"));
        }

        model_internal::_doValidationCacheOfSales_con_status = validationFailures;
        model_internal::_doValidationLastValOfSales_con_status = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfCurrency_name : Array = null;
    model_internal var _doValidationLastValOfCurrency_name : String;

    model_internal function _doValidationForCurrency_name(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfCurrency_name != null && model_internal::_doValidationLastValOfCurrency_name == value)
           return model_internal::_doValidationCacheOfCurrency_name ;

        _model.model_internal::_currency_nameIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isCurrency_nameAvailable && _internal_currency_name == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "currency_name is required"));
        }

        model_internal::_doValidationCacheOfCurrency_name = validationFailures;
        model_internal::_doValidationLastValOfCurrency_name = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfNo_of_days : Array = null;
    model_internal var _doValidationLastValOfNo_of_days : String;

    model_internal function _doValidationForNo_of_days(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfNo_of_days != null && model_internal::_doValidationLastValOfNo_of_days == value)
           return model_internal::_doValidationCacheOfNo_of_days ;

        _model.model_internal::_no_of_daysIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isNo_of_daysAvailable && _internal_no_of_days == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "no_of_days is required"));
        }

        model_internal::_doValidationCacheOfNo_of_days = validationFailures;
        model_internal::_doValidationLastValOfNo_of_days = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfSales_con_date : Array = null;
    model_internal var _doValidationLastValOfSales_con_date : String;

    model_internal function _doValidationForSales_con_date(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfSales_con_date != null && model_internal::_doValidationLastValOfSales_con_date == value)
           return model_internal::_doValidationCacheOfSales_con_date ;

        _model.model_internal::_sales_con_dateIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isSales_con_dateAvailable && _internal_sales_con_date == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "sales_con_date is required"));
        }

        model_internal::_doValidationCacheOfSales_con_date = validationFailures;
        model_internal::_doValidationLastValOfSales_con_date = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfSales_con_code : Array = null;
    model_internal var _doValidationLastValOfSales_con_code : String;

    model_internal function _doValidationForSales_con_code(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfSales_con_code != null && model_internal::_doValidationLastValOfSales_con_code == value)
           return model_internal::_doValidationCacheOfSales_con_code ;

        _model.model_internal::_sales_con_codeIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isSales_con_codeAvailable && _internal_sales_con_code == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "sales_con_code is required"));
        }

        model_internal::_doValidationCacheOfSales_con_code = validationFailures;
        model_internal::_doValidationLastValOfSales_con_code = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfCustomer : Array = null;
    model_internal var _doValidationLastValOfCustomer : String;

    model_internal function _doValidationForCustomer(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfCustomer != null && model_internal::_doValidationLastValOfCustomer == value)
           return model_internal::_doValidationCacheOfCustomer ;

        _model.model_internal::_customerIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isCustomerAvailable && _internal_customer == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "customer is required"));
        }

        model_internal::_doValidationCacheOfCustomer = validationFailures;
        model_internal::_doValidationLastValOfCustomer = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfSc_remarks : Array = null;
    model_internal var _doValidationLastValOfSc_remarks : String;

    model_internal function _doValidationForSc_remarks(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfSc_remarks != null && model_internal::_doValidationLastValOfSc_remarks == value)
           return model_internal::_doValidationCacheOfSc_remarks ;

        _model.model_internal::_sc_remarksIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isSc_remarksAvailable && _internal_sc_remarks == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "sc_remarks is required"));
        }

        model_internal::_doValidationCacheOfSc_remarks = validationFailures;
        model_internal::_doValidationLastValOfSc_remarks = value;

        return validationFailures;
    }
    

}

}
